-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
made closure param mutable #677
Conversation
PR missing one of the required labels: {'enhancement', 'documentation', 'new feature', 'dependencies', 'internal', 'breaking-change', 'bug'} |
PR missing one of the required labels: {'documentation', 'dependencies', 'breaking-change', 'enhancement', 'internal', 'new feature', 'bug'} |
include/zenoh_commons.h
Outdated
@@ -1927,7 +1927,7 @@ const struct z_loaned_closure_sample_t *z_closure_sample_loan(const struct z_own | |||
#if defined(UNSTABLE) | |||
ZENOHC_API | |||
void z_closure_zid_call(const struct z_loaned_closure_zid_t *closure, | |||
const z_id_t *z_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
z_id_t is non-owned object, there is no benefit in having it non-const, also leads to questions whether the user is in the right to call free on it ?
Fix related to eclipse-zenoh/zenoh#1372
Preparation for further making
z_take
operation forz_loaned_xxx_t*
callback parameters. This will allow user to take ownership of data passed to callback without clone operation.This update is unsafe for C++, as in the zenoh-cpp it's already possible to perform
std::move
as soon as the callback parameter is not const. But in this update this is unsafe as on the rust side the non-owned objects are actually passed to callback. I.e. on rust side it's now&mut Sample
represented asz_loaned_sample_t*
. This means that it's prohibited at this moment to convertz_loaned_sample_t*
toz_owned_sample_t*
(which isOption<Sample>
on rust side). But zenoh-cpp is built on assumption that it's safe to do this conversion because until this moment it was not possible to getz_loaned_xxx_t*
reference directly to object other thanz_owned_xxx_t
.The safety correction will be made in separate update to accelerate C++ API updating and to make verifying of safety update easier